window.Arrow = class Arrow {
  constructor(x, y, color, angle) {
    this.x = x;
    this.y = y;
    this.color = color || "red";
    this.angle = angle;
  }

  draw() {
    // 关于这里书中采用的方式是利用translate 来进行处理，然后利用save与restore来进行平移状态的恢复
    cxt.beginPath();
    cxt.save();

    cxt.translate(this.x, this.y);
    // cxt.rotate((Math.PI / 180) * this.angle);
    //    cxt.moveTo(this.x, this.y+15);
    // //    cxt.lineTo(50,50)
    //    cxt.lineTo(this.x+80, this.y+15);
    //    cxt.lineTo(this.x+80, this.y+45);

    //    cxt.lineTo(this.x+140, this.y);

    //    cxt.lineTo(this.x+80, this.y-45);
    //    cxt.lineTo(this.x+80, this.y-15);

    //    cxt.lineTo(this.x, this.y-15);

    cxt.moveTo(0, 15);
    cxt.lineTo(80, 15);
    cxt.lineTo(80, 45);

    cxt.lineTo(140, 0);

    cxt.lineTo(80, -45);
    cxt.lineTo(80, -15);

    cxt.lineTo(0, -15);

    cxt.closePath();
    cxt.strokeStyle = this.color;
 
   

    cxt.stroke();

    cxt.restore()

    
  }
};
